#!/bin/bash

# 遍历当前目录下的所有子目录
for dir in */; do
    # 进入子目录
    cd "$dir" || continue

    # 检查该目录是否是一个Git仓库
    if [ -d ".git" ]; then
        echo "Processing Git repository in $dir"

        # 切换到master分支
        git checkout master
        # 更新master分支
        git pull origin master
        # 检查切换是否成功
        if [ $? -ne 0 ]; then
            echo "Failed to switch to master in $dir"
        else
            echo "Switched to master in $dir"
        fi
    else
        echo "$dir is not a Git repository"
    fi

    # 返回上一级目录
    cd ..
done

echo "All done!"
